package net.liteheaven.xblib.common.res;

import android.content.Context;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class AssetUtil {

	public static String getFromAssets(Context context, String fileName) {
		InputStreamReader inputReader = null;
		BufferedReader bufReader = null;
		String result = "";
		try {
			inputReader = new InputStreamReader(context.getResources().getAssets().open(fileName));
			bufReader = new BufferedReader(inputReader);
			String line;
			while ((line = bufReader.readLine()) != null){
				result += line;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try{
				if (bufReader != null){
					bufReader.close();
				}
				if (inputReader != null){
					inputReader.close();
				}
			}catch (Exception e){
			}
		}
		return result;
	}
}
